$(function () {

    // 获取当前窗口的宽度
    var winWidth = $(window.parent.document).find("#wrapper").width();

    $.fn.bTableUtil = function(options){
        var opts = $.extend({}, $.fn.bTableUtil.defaults, options);
        $('#'+opts.id).bootstrapTable({
            url : opts.url,
            height : opts.height!=undefined?opts.height:winWidth<=415?721:$(window.parent.document).find("#wrapper").height() - 320,
            width : opts.width!=undefined?opts.width:$(window).width(),
            showColumns : opts.showColumns!=undefined?opts.showColumns:true,
            formId : opts.formId,
            pagination : opts.pagination!=undefined?opts.pagination:true,
            sortName : opts.sortName!=undefined?opts.sortName:'',
            sortOrder : opts.sortOrder!=undefined?opts.sortOrder:'',
            clickToSelect : opts.clickToSelect!=undefined?opts.clickToSelect:true,
            pageSize : opts.pageSize!=undefined?opts.pageSize:winWidth<=415?3:13,
            cardView : opts.cardView!=undefined?opts.cardView:winWidth<=415?true:false,
            toolbars : opts.toolbars,
            columns : opts.columns
        })
    }

    $.fn.bTableUtil.defaults = {
        height:winWidth<=415?721:$(window.parent.document).find("#wrapper").height() - 320,
        width:$(window).width(),
        showColumns:true,
        pagination : true,
        clickToSelect: true,// 单击某一行的时候选中某一条记录
        pageSize : winWidth<=415?3:13,
        cardView : winWidth<=415?true:false// 根据屏幕大小来决定是否试图展示
    }
});